import com.sun.org.apache.bcel.internal.classfile.LineNumber;

import java.io.*;

public class FileOutDemo {
    public static void main(String[] args) {
        String file = "d://b.txt";
        try {
            FileReader fr = new FileReader(file);
            char [] c = new char[1024];
            try {
                fr.read(c);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            System.out.println(c);

        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
    public static void main2(String[] args) {
        String src = "b.txt";
        String x;
        FileReader file =null;
        LineNumberReader no =null;
        try {
            file = new FileReader(src);
            no =new LineNumberReader(file);

            while(true){

                System.out.println("#"+no.getLineNumber()+" "+x);
            }
        } catch (FileNotFoundException e) {
            System.out.println("找不到文件");
            throw new RuntimeException(e);
        }finally{
            try {
                file.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            no.close();
        }
    }
    public static void main1(String[] args) {
        String file = "D://b.txt";

        try {
            FileOutputStream fos = new FileOutputStream(file);
            DataOutputStream dos = new DataOutputStream(fos);
            FileInputStream  fis = new FileInputStream(file);
            DataInputStream  dis = new DataInputStream(fis);
            byte b [] = new byte[1024];
           dos.write(104);
            dos.write(105);
            fis.read(b);
            fos.write(b);
            fos.close();
            fis.close();
        } catch (IOException e) {

            throw new RuntimeException(e);
        }
    }
}
